package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.rm.zeyou.entity.Technician;
import com.rm.zeyou.entity.User;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.PayoutConfigService;
import com.rm.zeyou.service.UserPayoutDetailService;
import com.rm.zeyou.util.login.LoginUtil;
import com.rm.zeyou.util.login.TechnicianLoginUtil;
import com.rm.zeyou.vo.request.SelectUserPayoutIndexVo;
import com.rm.zeyou.vo.response.ConfirmPayoutResponseVo;
import com.rm.zeyou.vo.response.SelectPayoutWayResponseVo;
import com.rm.zeyou.vo.response.SelectUserPayoutIndexResponseVo;
import com.rm.zeyou.vo.response.UserPayoutVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户提现记录表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:09
 */
@Api(tags = "用户提现相关")
@RestController
@RequestMapping("/api/userPayoutDetail")
public class UserPayoutDetailController {
    @Resource
    private UserPayoutDetailService userPayoutDetailService;
    @Resource
    private LoginUtil loginUtil;
    @Resource
    private TechnicianLoginUtil technicianLoginUtil;
    @Resource
    private PayoutConfigService payoutConfigService;

    @ApiOperation("用户获取提现方式")
    @GetMapping("selectPayoutWay")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<List<SelectPayoutWayResponseVo>> selectPayoutWay() {
        User user = loginUtil.getUser();
        return payoutConfigService.selectPayoutWay(user);
    }

    @ApiOperation("技师获取提现方式")
    @GetMapping("selectTechnicianPayoutWay")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<List<SelectPayoutWayResponseVo>> selectTechnicianPayoutWay() {
        Technician technician = technicianLoginUtil.getTechnician();
        return payoutConfigService.selectTechnicianPayoutWay(technician);
    }

    @ApiOperation("用户提现页面")
    @PostMapping("selectUserPayoutIndex")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<SelectUserPayoutIndexResponseVo> selectUserPayoutIndex(@RequestBody SelectUserPayoutIndexVo requestVo) {
        User user = loginUtil.getUser();
        return userPayoutDetailService.selectUserPayoutIndex(user, requestVo);
    }


    @ApiOperation("用户提现")
    @PostMapping("userPayout")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<Integer> userPayout(@RequestBody UserPayoutVo requestVo) {
        User user = loginUtil.getUser();
        return userPayoutDetailService.userPayout(user, requestVo);
    }


    @ApiOperation("用户确认提现列表")
    @PostMapping("userConfirmPayout")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<List<ConfirmPayoutResponseVo>> userConfirmPayout() {
        User user = loginUtil.getUser();
        return userPayoutDetailService.userConfirmPayout(user);
    }

}
